package com.bgs.service.impl;

import com.bgs.common.R;
import com.bgs.pojo.Products;
import com.bgs.mapper.ProductsMapper;
import com.bgs.pojo.vo.FourProducts;
import com.bgs.service.ProductsService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * <p>
 * 品类 服务实现类
 * </p>
 *
 * @author Asia
 * @since 2021-09-14
 */
@Service
public class ProductsServiceImpl extends ServiceImpl<ProductsMapper, Products> implements ProductsService {
    @Autowired
    private ProductsMapper productsMapper;
    @Override
    public R zeroGetProducts() {
        List<Products> products=productsMapper.zeroGetProducts();
        return R.ok().data("products",products);
    }

    /**
     * 查询所有种类
     * @return
     */
    @Override
    public R fourKindList() {
        List<FourProducts> list = productsMapper.fourKindList();
        return R.ok().data("data",list);
    }

    /**
     * 添加新商品
     * @return
     */
    @Override
    public R fourAddKind(Products products) {
        productsMapper.fourAddKind(products);
        return R.ok().data("data",1);
    }

    @Override
    public R fourdelKind(Products products) {
        productsMapper.fourdelKind(products);
        return R.ok().data("data",1);
    }


}
